import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const login = r => require.ensure([], () => r(require('@/page/login')), 'login');
const manage = r => require.ensure([], () => r(require('@/page/manage')), 'manage');

const addGoods = r => require.ensure([], () => r(require('@/page/addGoods')), 'addGoods');
const userList = r => require.ensure([], () => r(require('@/page/userList')), 'userList');
const shop_register_List = r => require.ensure([], () => r(require('@/page/shop_register_List')), 'shop_register_List');

const register = r => require.ensure([], () => r(require('@/page/register')), 'register');
const register_shop = r => require.ensure([], () => r(require('@/page/register_shop')), 'register_shop');
const admin_login = r => require.ensure([], () => r(require('@/page/admin_login')), 'admin_login');
const EditGoods = r => require.ensure([], () => r(require('@/page/EditGoods')), 'EditGoods');
const goodlist = r => require.ensure([], () => r(require('@/page/goodlist')), 'goodlist');
const update_user_account = r => require.ensure([], () => r(require('@/page/update_user_account')), 'update_user_account');
const admin_manage = r => require.ensure([], () => r(require('@/page/admin_manage')), 'admin_manage');
const add_address = r => require.ensure([], () => r(require('@/page/add_address')), 'add_address');
const addressList = r => require.ensure([], () => r(require('@/page/addressList')), 'addressList');

const routes = [
	{
		path: '/',
		component: login
	},
    {
        path: '/register',
        component: register
    },
	{
		path: '/admin_login',
		component: admin_login
	},
	{
		path: '/admin_manage',
		component: admin_manage,
		meta: ['数据管理', '商家列表1'],
		children:[
			{
				path: '/userList',
				component: userList,
				meta: ['数据管理', '用户列表'],
			},


			{
				path: '/shop_register_List',
				component: shop_register_List,
				meta: ['数据管理', '商家列表'],
			},
		]
	},
	{
		path: '/manage',
		component: manage,
		name: '',
		children: [{
			path: '/addGoods',
			component: addGoods,
			meta: ['添加数据', '添加商品'],
		},
			{
				path: '/EditGoods',
				component: EditGoods,
				meta: ['添加数据', '修改商品'],
			},
			{
				path: '/add_address',
				component: add_address,
				meta: ['数据管理', '用户列表'],
			},
			{
				path: '/addressList',
				component: addressList,
				meta: ['数据管理', '用户列表'],
			},
            {
				path: '/update_user_account',
				component: update_user_account ,
				meta: ['数据管理', '商家列表1'],
			},{
				path: '/goodlist',
				component: goodlist ,
				meta: ['数据管理', '商家列表1'],
			},{
                path: '/register_shop',
                component: register_shop,
                meta: ['数据管理', '订单列表'],
            }]
	}
]

export default new Router({
	routes,
	strict: process.env.NODE_ENV !== 'production',
})
